home *** CD-ROM | disk | FTP | other *** search
- /*************************************************************************************************
-
-
- Perform Apple Events
-
- Written by Peter Falco, Apple Computer
-
- April, 1995
-
- *************************************************************************************************/
-
-
- #include <AppleEvents.h>
- #include <Drag.h>
- #include <GestaltEqu.h>
- #include <Memory.h>
- #include <SegLoad.h>
-
- #include "QD3DtoQTVR.h"
- #include "AEVT.h"
- #include "extern.h"
- #include "file.h"
- #include "Panorama.h"
- #include "document.h"
-
-
- void DoHighLevelEvent(EventRecord *ev)
- {
- OSErr err;
-
- err = AEProcessAppleEvent(ev);
- }
-
-
-
- pascal OSErr MyAEHandleOAPP(AppleEvent *theAppleEvent,AppleEvent *reply,long refCon)
- {
- OSErr err = noErr ;
- SFTypeList theTypeList = {'3DMF'};
- StandardFileReply theReply;
-
- *theAppleEvent = *theAppleEvent;
- *reply = *reply;
- refCon = refCon;
-
-
- StandardGetFilePreview(0L, 1, theTypeList, &theReply);
-
- while (theReply.sfGood)
- {
- MyConvert3DMFToPano(&theReply.sfFile);
- StandardGetFilePreview(0L, 1, theTypeList, &theReply);
- }
-
- SendQuitApp();
-
- return err;
- }
-
-
- //-----------------------------------------------------------------------
- // handler for the open document appleevent handler
-
- pascal OSErr MyAEHandleODOC(AppleEvent *theAppleEvent,AppleEvent *reply,long refCon)
- {
- FSSpec myFSS;
- AEDescList docList;
- OSErr err,
- ignoreErr;
- long index,
- itemsInList;
- Size actualSize;
- AEKeyword keywd;
- DescType returnedType;
-
- *theAppleEvent = *theAppleEvent;
- *reply = *reply;
- refCon = refCon;
-
- err = AEGetParamDesc(theAppleEvent,keyDirectObject,typeAEList,&docList);
- if (err == noErr) {
-
- // see how many descriptor items are in the list
- // this is the number of documents we want to open
- err = AECountItems(&docList,&itemsInList);
-
- // now get each descriptor record from the list
- // coerce the returned data to an FSSpec record, and
- // open the asoociated file
-
- for (index=1; index <= itemsInList && err == noErr; index++) {
-
- err = AEGetNthPtr( &docList,
- index,
- typeFSS,
- &keywd,
- &returnedType,
- (Ptr)&myFSS,
- sizeof(myFSS),
- &actualSize);
-
- if (err == noErr) {
-
- FInfo fndrInfo ;
-
- // we now have a valid FSSpec to reference the file, we need to know
- // what type the file is to determine which file open function to call
- // we can determine this from the finder info for the file
-
- err = FSpGetFInfo( &myFSS, &fndrInfo );
-
- // if we got that ok, then we switch on the file
- // type (we don't care about the creator type)
-
- if (err == noErr) {
-
- switch( fndrInfo.fdType ) {
- case 'TEXT':
- case '3DMF':
- MyConvert3DMFToPano(&myFSS);
- break ;
- default:
- SendQuitApp();
- break ;
- }
- }
- }
- }
- ignoreErr = AEDisposeDesc(&docList);
- SendQuitApp();
- }
- return err ;
- }
-
- //-----------------------------------------------------------------------
- // handler for the print document event handler
-
- pascal OSErr MyAEHandlePDOC(AppleEvent *theAppleEvent,AppleEvent *reply,long refCon)
- {
- return noErr;
- }
-
-
- pascal OSErr MyAEHandleQUIT(AppleEvent *theAppleEvent,AppleEvent *reply,long refCon)
- {
- OSErr err = noErr ; // used as return value
- WindowPtr theWindow;
-
- gQuitting = true;
-
- // attempt to close the document if window left open
- theWindow = (WindowPtr)FrontWindow();
- if (theWindow)
- MyCloseDocument((DocumentPtr ) (((WindowPeek) theWindow)->refCon));
-
- // if we closed everything up successfully, we can return noErr, otherwise
- // indicate to sender of the 'quit' aevt that we canceled
-
- if (gQuitting) {
- gQuit = true; // user didn't cancel
- err = AEDisposeDesc(&pSelfAddress); // Dispose of my self-addressed descriptor.
- }
- else {
- err = userCanceledErr ;
- }
-
- return err ;
- }
-
-
-
- void SendQuitApp( void )
- {
- AppleEvent myAppleEvent, reply;
- OSErr err;
-
- // Create the Apple Event.
- err = AECreateAppleEvent( kCoreEventClass,
- kAEQuitApplication,
- &pSelfAddress,
- kAutoGenerateReturnID,
- kAnyTransactionID,
- &myAppleEvent);
-
- // Send the Apple Event.
- err = AESend( &myAppleEvent,
- &reply,
- kAENoReply+kAENeverInteract,
- kAENormalPriority,
- kAEDefaultTimeout,
- nil,
- nil);
-
- AEDisposeDesc(&myAppleEvent); // Dispose of the Apple Event.
- } // SendQuitApp
-
-
- void SendOpenDoc(FSSpec *myFSSpec)
- {
-
-
- }
-
-
-
- void SendPrintDoc(FSSpec *myFSSpec)
- {
-
- }
-
-
-